/*--------------------------------------------------------------------------
  Project::MONDIALI SCI ALPINISMO
  Package::States
  Class::ScenarioCreationState
  File ScenarioCreationState.h
  --------------------------------------------------------------------------
  * METHODS AND CLASS PARAMETERS


  --------------------------------------------------------------------------
  * FUNCTIONS DESCRIPTION
  
	...

  --------------------------------------------------------------------------
  * COPYRIGHT

  --------------------------------------------------------------------------
  * INFO ABOUT AUTHOR AND VERSIONS
  Author:	Tino Giorgio	Data: 
  Rev1:			Data:

  --------------------------------------------------------------------------
  * E-MAIL & CONTACTS

  GIORGIO TINO:	tinoshi@libero.it
	           	shapeofangels@hotmail.com
	            giorgio.tino@studenti.polito.it

  --------------------------------------------------------------------------*/

#if !defined(SCENARIOCREATIONSTATE_H)
#define SCENARIOCREATIONSTATE_H

#include <stdio.h>

#include "State.h"
#include "LoadingInfo.h"

/* DEFINES */
#ifndef NUM_MAP_WIDGETS 
#define NUM_MAP_WIDGETS 3
#endif
#ifndef CAMERA_PROGRESS
#define CAMERA_PROGRESS 0.2f
#endif

#define NEWSCENARIO 0
#define LOADSCENARIO 1

#define EDITING_STATE				0
#define CAMERA_REPOSITIONING_STATE	1
#define MOVIE_STATE					2

class GUI;
class NewScenarioState;
class LoadScenarioState;
class sgdLineSegment3;
class puText;
class FPSTest;
class MapImage;
class Land;
class Mouse;
class Keyboard;
class Camera;
class Scenegraph;
class ulClock;

class ScenarioCreationState : public State
{
public:
	ScenarioCreationState(State* os,LoadingInfo* li,int backTo);
	virtual ~ScenarioCreationState();
	
	// class 'callbacks' (they aren't callbacks really...)
	void load(const char* filename);
    void display(void);
    void resize(int w, int h);
    void keyUp(unsigned char key, int x, int y);
    void keyDown(unsigned char key, int x, int y);
    void specialUp(int key, int x, int y);
    void specialDown(int key, int x, int y);
    void motion(int newx, int newy); 
    void passive(int newx, int newy);
    void mouse(int button, int state, int mouseX, int mouseY);
    State* idle(void);
	void reset();
	void goBack();
	
	void loadScenario();
	void saveScenario();

	void bindTextures();
	void createStates();

	void loadCameraPosition(FILE* f);
	void saveCameraPosition(FILE* f);

	void start();
	void end();
	void play();
	void stop();
	void forward();
	void rewind();

	LoadingInfo *info;
    
private:
    ulClock *ck;
	Scenegraph *scene;
	Camera *camera;

	Mouse *ms;
	Keyboard *kb;

	State *oldState,*nextState;

	Land *l;

	int backTo;
	
	int v;
	float x,y,z,h,p,r;

	int wireframe;

	MapImage* mapsWidget[NUM_MAP_WIDGETS];
	int current_map_widget;

	int inner_state;

	// Test
	FPSTest *fps;
	puText		*fps_text;
	char		fps_text_legend[1024];

	GUI *gui;

	// trial ???
	sgdLineSegment3 *ls;

	// file names
	char scenario_file_name[1024];
	char dem_filename[1024];
	char obj_filename[1024];
	char tex_filename[1024];
	char map_filename[1024];
	char wpn_filename[1024];
	char cmv_filename[1024];

	void renameScenarioFile(LoadingInfo* li);

	void editingKeyboard(unsigned char key, int x, int y);
	void cameraKeyboard(unsigned char key, int x, int y);
	void movieKeyboard(unsigned char key, int x, int y);
};

#endif // !defined(SCENARIOCREATIONSTATE_H_)
